package com.ssrs.platform.code;

import com.ssrs.framework.extend.annotation.ExtendItem;
import com.ssrs.platform.FixedCodeType;
import com.ssrs.platform.PlatformPlugin;
import com.ssrs.platform.extend.CodeService;
import com.ssrs.platform.util.PlatformUtil;

/**
 * 是或否
 *
 * @author ssrs
 */
@ExtendItem(
        plugin = PlatformPlugin.class,
        extendService = CodeService.class,
        description = "是或否代码项"
)
public class YesOrNo extends FixedCodeType {
    public static final String CODETYPE = "YesOrNo";

    public static final String YES = "Y";
    public static final String NO = "N";

    public YesOrNo() {
        super(CODETYPE, "是或否", false, false);
        addFixedItem(YES, "是", null);
        addFixedItem(NO, "否", null);
    }

    public static boolean isYes(String str) {
        return YES.equals(str);
    }

    public static boolean isNo(String str) {
        return !isYes(str);
    }

    public static String getName(String code) {
        return PlatformUtil.getCodeMap(CODETYPE).getStr(code);
    }
}
